import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
import { classByDepartment } from './assignScore.api';
//列表数据
import { courselist, classlist } from '@/views/assignSubmit/assignSubmit.api';
const statusOptions = [
  { label: '未打分', value: '0' },
  { label: '已打分', value: '1' },
];
export const columns: BasicColumn[] = [
  {
    title: '实验课班级',
    align: 'center',
    dataIndex: 'className',
  },
  {
    title: '姓名',
    align: 'center',
    dataIndex: 'studentName',
  },
  {
    title: '学号',
    align: 'center',
    dataIndex: 'studentNumber',
  },
  {
    title: '所属课程',
    align: 'center',
    dataIndex: 'courseName',
  },
  {
    title: '打分状态',
    align: 'center',
    dataIndex: 'status',
    customRender: ({ record }) => {
      const color = record.status == 0 ? 'red' : 'green';
      const text = record.status == 0 ? '未打分' : '已打分';
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '成绩分数',
    align: 'center',
    dataIndex: 'score',
  },
  {
    title: '打分时间',
    align: 'center',
    dataIndex: 'createTime',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '实验课班级',
    field: 'classId',
    component: 'ApiSelect',
    componentProps: {
      api: classByDepartment,
      // resultField: 'records',
      labelField: 'className',
      valueField: 'id',
      immediate: false,
    },
    colProps: { span: 5 },
  },
  {
    label: '实验名称',
    field: 'courseName',
    component: 'JInput',

    colProps: { span: 5 },
  },
  {
    label: '打分状态',
    field: 'recordsStatus',
    component: 'Select',
    componentProps: {
      options: statusOptions,
    },
    colProps: { span: 5 },
  },
  {
    label: '学生姓名',

    field: 'studentName',
    component: 'JInput',
    colProps: { span: 4 },
    componentProps: {
      type: '',
    },
  },
  {
    label: '学生学号',

    field: 'studentNumber',
    component: 'JInput',
    colProps: { span: 4 },
    componentProps: {
      type: '',
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '实验课名称',
    field: 'className',
    component: 'Input',
  },

  {
    label: '学生姓名',
    field: 'studentName',
    component: 'Input',
  },
  {
    label: '学号',
    field: 'studentNumber',
    component: 'Input',
  },
  {
    label: '作业所属课程',
    field: 'courseName',
    component: 'Input',
  },
  {
    label: '教师打分',
    field: 'score',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  studentId: { title: '学生id', order: 0, view: 'text', type: 'string' },
  courseId: { title: '课程id', order: 1, view: 'text', type: 'string' },
  assignmentName: { title: '作业名称', order: 3, view: 'text', type: 'string' },
  assignmentPath: { title: '作业路径', order: 4, view: 'text', type: 'string' },
  score: { title: '成绩分数', order: 5, view: 'text', type: 'string' },
  status: { title: '状态 1.待审核 2.已审核', order: 6, view: 'number', type: 'number' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
